//
//  verifyPassAndPhone.m
//  Restaurant
//
//  Created by wanghuan on 15/5/4.
//  Copyright (c) 2015年 wanghuan. All rights reserved.
//

#import "verifyPassAndPhone.h"

@implementation verifyPassAndPhone

//验证手机号
+(BOOL)checkPhoneNumber:(NSString *)phoneNumber

{
    //第一位必须是1开头 第二位可以是3578
    NSString *pattern = @"^1+[3578]+\\d{9}";
    //验证是否为有效的正规表达式
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
    BOOL isMatch = [pred evaluateWithObject:phoneNumber];
    return isMatch;
}

//验证密码
+(BOOL)checkPassword:(NSString *)password

{
    NSString *pattern = @"^(?![0-9]+$)(?![a-zA-Z]+$)[a-zA-Z]|[0-9]|[a-zA-Z0-9]{6,14}";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", pattern];
    BOOL isMatch = [pred evaluateWithObject:password];
    return isMatch;
}


@end
